using System.Web.Compilation;

namespace VideoSeller.Core.Localization
{
	public sealed class CustomResourceProviderFactory : ResourceProviderFactory
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomResourceProviderFactory"/> class.
        /// </summary>
        public CustomResourceProviderFactory() {
        }

        /// <summary>
        /// Creates a global resource provider.
        /// </summary>
        /// <param name="classKey">The name of the resource class.</param>
        /// <returns>
        /// An <see cref="T:System.Web.Compilation.IResourceProvider"></see>.
        /// </returns>
        public override IResourceProvider CreateGlobalResourceProvider(string classKey)
        {
            return new CustomResourceProvider(null, classKey);
        }

        /// <summary>
        /// Creates a local resource provider.
        /// </summary>
        /// <param name="virtualPath">The path to a resource file.</param>
        /// <returns>
        /// An <see cref="T:System.Web.Compilation.IResourceProvider"></see>.
        /// </returns>
        public override IResourceProvider CreateLocalResourceProvider(string virtualPath)
        {
            virtualPath = System.IO.Path.GetFileName(virtualPath);
            return new CustomResourceProvider(virtualPath, null);
        }
    }
}
